﻿@model GitCandy.Models.CommitModel

<div class="page-divider"></div>
<div>@string.Format(SR.Repository_ChangedSummary, Model.Changes.Count(), Model.Changes.Sum(s => s.LinesAdded), Model.Changes.Sum(s => s.LinesDeleted))</div>
@foreach (var change in Model.Changes)
{
    var removed = change.ChangeKind == LibGit2Sharp.ChangeKind.Deleted || change.ChangeKind == LibGit2Sharp.ChangeKind.Ignored;
    <div class="row">
        <div>
            <div class="span2 pull-left">@change.ChangeKind.ToLocateString() +@change.LinesAdded -@change.LinesDeleted</div>
            <div class="span10 pull-right">
                @if (change.OldPath != change.Path)
                {
                    @change.OldPath @Html.Raw(" → ")
                }
                @(removed
                    ? Html.Raw(change.Path)
                    : Html.ActionLink(change.Path, "Blob", Html.OverRoute(new { path = (Model.ReferenceName ?? Model.Sha) + "/" + change.Path })))
            </div>
        </div>
    </div>
}
@foreach (var change in Model.Changes)
{
    var removed = change.ChangeKind == LibGit2Sharp.ChangeKind.Deleted || change.ChangeKind == LibGit2Sharp.ChangeKind.Ignored;
    <div class="page-divider"></div>
    <div class="row">
        <div>
            <div class="span2 pull-left">@change.ChangeKind.ToLocateString() +@change.LinesAdded -@change.LinesDeleted</div>
            <div class="span10 pull-right">
                @if (change.OldPath != change.Path)
                {
                    @change.OldPath @Html.Raw(" → ")
                }
                @(removed
                    ? Html.Raw(change.Path)
                    : Html.ActionLink(change.Path, "Blob", Html.OverRoute(new { path = (Model.ReferenceName ?? Model.Sha) + "/" + change.Path })))
            </div>
        </div>
        @if (!removed)
        {
            <div class="span12">
                <pre><code class="language diff">@change.Patch</code></pre>
            </div>
        }
    </div>
}
